package com.choosefine.paycenter.webgateway.pay.web.controller;

import com.choosefine.paycenter.common.dto.JSONResult;
import com.choosefine.paycenter.common.utils.JSONResultGenerator;
import com.choosefine.paycenter.pay.service.BankService;
import com.choosefine.paycenter.pay.service.BankUnionService;
import com.choosefine.paycenter.pay.service.CityService;
import com.choosefine.paycenter.pay.service.ProvinceService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 潘钱钦（qianqinpan@outlook.com）
 * @create 2017-05-08 19:34
 **/
@Api(value = "支行选择",description = "潘钱钦")
@RestController
@RequestMapping("account/ubank")
public class UBankController {
    @Autowired
    private BankService bankService;

    @Autowired
    private BankUnionService bankUnionService;

    @Autowired
    private CityService cityService;

    @Autowired
    private ProvinceService provinceService;

    @GetMapping("/province")
    public JSONResult province(){
        return JSONResultGenerator.buildOperSuccessResult(provinceService.provinceList());
    }

    @GetMapping("/city/{provinceCode}")
    public JSONResult city(@PathVariable String provinceCode){
        return JSONResultGenerator.buildOperSuccessResult(cityService.selectCityListByProvinceCode(provinceCode));
    }

    @GetMapping("/ubank/{bankCode}/{cityCode}")
    public JSONResult uBank(@PathVariable String bankCode,@PathVariable String cityCode){
        return JSONResultGenerator.buildOperSuccessResult(bankUnionService.selectBankUnionByCityCodeAndBankCode(bankCode,cityCode));
    }

    @GetMapping("/bank")
    public JSONResult bank(){
        return JSONResultGenerator.buildOperSuccessResult(bankService.selectSupportBankList());
    }
}
